//
//  ZDDMainViewController.swift
//  小蜗牛_新浪微博
//
//  Created by 周冬冬 on 16/6/25.
//  Copyright © 2016年 我的mac. All rights reserved.
//

import UIKit

class ZDDMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
//自定义TabBar
        let tabBar = ZDDTabBar()
        
        //设置代理对象
        tabBar.ZDDDelegate = self
        
        setValue(tabBar, forKey: "tabBar")
       addChildViewController(ZDDHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        
        addChildViewController(ZDDMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        
        addChildViewController(ZDDDiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        
        addChildViewController(ZDDProfileTableViewController(), title: "我", imageName: "tabbar_profile")
        
        
        
    }

    func addChildViewController(vc:UIViewController,title:String,imageName:String) {
        
        
        //设置title
        vc.title = title
        
        vc.tabBarItem.image = UIImage(named: imageName)
        
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        
        let navc = UINavigationController(rootViewController: vc)
        
        addChildViewController(navc)
        
        
        
    }
   
}
//实现代理方法

extension ZDDMainViewController:ZDDTabBarDelegate{
    
    func composeButtonClick(){
        
        print("弹出控制器")
        let ComposeVC = ZDDComposeViewController()
        
        let Navc = UINavigationController(rootViewController: ComposeVC)
        presentViewController(Navc, animated: true, completion: nil)
        
        
    }
    
    
    
    
}